package com.itheima.api.treeset.demo07;

public class Student implements Comparable<Student> {

    private String name;
    private int chineseScore;
    private int mathScore;
    private int englishScore;

    public Student() {

    }

    public Student(String name, int chineseScore, int mathScore, int englishScore) {
        this.name = name;
        this.chineseScore = chineseScore;
        this.mathScore = mathScore;
        this.englishScore = englishScore;
    }

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public int getChineseScore() {
        return chineseScore;
    }

    public void setChineseScore(int chineseScore) {
        this.chineseScore = chineseScore;
    }

    public int getMathScore() {
        return mathScore;
    }

    public void setMathScore(int mathScore) {
        this.mathScore = mathScore;
    }

    public int getEnglishScore() {
        return englishScore;
    }

    public void setEnglishScore(int englishScore) {
        this.englishScore = englishScore;
    }

    public int getTotal(){
        return this.chineseScore + this.mathScore + this.englishScore;
    }


    @Override
    public int compareTo(Student o) {
        int result = o.getTotal() - this.getTotal();
        int result2 = result == 0 ? o.chineseScore - this.chineseScore : result;
        int result3 = result2 == 0 ? o.mathScore - this.mathScore : result2;
        int result4 = result3 == 0 ? o.name.compareTo(this.name) : result3;
        return result4;
    }
}
